﻿@using EasyCourse.Model;
@{
    Layout = null;
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>资源管理</title>
    @Html.Partial("~/Views/Share/PublicHeader.cshtml")
</head>
<body>
    @Html.Partial("~/Views/Share/PublicTopNav2.cshtml")
    <div class="container">
        <div class="row">
            <h1 class="topTitle-h1">康复治疗微课程网络学习平台<br><small>广州中医药大学康复治疗微课程网络学习平台</small></h1>
        </div>
    </div>
    <div class="container-fluid yue-nav mb15">
        <div class="container">
            <div class="row">
                <ul>
                    <li><a target="_blank" href='@Url.Action("Index","Home")'>课程群首页</a></li>
                    <li><a href="@Url.Action("MyList","Discussion")">论坛讨论</a></li>
                    <li><a class="current" href="javascript:void(0);">资源管理</a></li>
                    <li><a href="@Url.Action("StudentPersonalInfo", "UserInfo")">个人信息</a></li>
                </ul>
            </div>
        </div>
    </div>
    <div class="container mainwrap">
        <div class="row">
            <div class="col-xs-2">
                <div class="dropdown theme-dropdown clearfix">
                    <a id="dropdownMenu1" href="#" role="button" class="sr-only dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a>
                    <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
                        <li class="active" role="presentation"><a role="menuitem" tabindex="-1" href="javascript:void(0)"><span class="glyphicon glyphicon-globe"></span> 资源共享管理</a></li>
                        <li role="presentation" class="divider"></li>
                        <li role="presentation"><a role="menuitem" tabindex="-1" href="@Url.Action("Add", "StudentResManage")"><span class="glyphicon glyphicon-plus"></span> 新增共享资源</a></li>
                    </ul>
                </div>
            </div>
            <div class="col-xs-10">
                <div class="panel panel-default mainwrap-part">
                    <div class="panel-heading">
                        <ol class="breadcrumb">
                            <li>资源管理</li>
                            <li class="active">资源共享管理</li>
                        </ol>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="form-group clearfix">
                                <div class="col-xs-4">
                                    <input type="text" class="form-control" id="resTitle" placeholder="请输入标题">
                                </div>
                                <div class=" col-xs-6">
                                    <button type="submit" class="btn btn-success" id="subBtn"><span class="glyphicon glyphicon-search"></span> 搜索</button>
                                </div>
                            </div>
                        </div>
                        <table class="table table-bordered tb1" id="tb1">
                            <thead>
                                <tr>
                                    <th width="20%">课程名称</th>
                                    <th width="20%">标题</th>
                                    <th width="30%">文件名</th>
                                    <th width="10%">创建人</th>
                                    <th width="10%">上传时间</th>
                                    <th width="10%">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                        <div class="row clearfix well" id="well">
                            <div class="pull-left sum" id="PagInfo"></div>
                            <div class=" center-block clearfix pull-right">
                                <ul class="pagination" id="PageTool"></ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    @Html.Partial("~/Views/Share/PublicFooter.cshtml")
    @Html.Partial("~/Views/Share/PublicCommonJs.cshtml");
    <script type="text/javascript">
        $(function () {
            $("#well").hide();
            getList(1);
            /*搜索时强制回到第一页*/
            $("#subBtn").click(function () { getList(1); });
        });
        function getList(pageNo) {
            var _html = "",
                _resTitle = $("#resTitle").val().trim(),
                _courseId = $.getUrlParam("CourseId");
            $.easyPost("@Url.Action("SearchMySelfResourceList", "StudentResManage")", { "PageNO": pageNo, "PageSize": 10, "CourseId": _courseId, "Title": _resTitle }, function (data) {
                if (!data.result) { showTips.open("data.message"); return; }
                var _rows = data.rows, len = _rows.length, time;
                if (len > 0) {
                    opts = {
                        totalPages: data.totalPage,
                        total: data.total,
                        currentPage: pageNo,
                        onPageClicked: function (event, originalEvent, type, page) {
                            getList(page);
                        }
                    };
                    initialPaginator(opts, "PageTool", "PagInfo");
                    for (var i = 0; i < len; i++) {
                        var item = _rows[i].Entity;
                        var _courseName = _rows[i].CourseName;
                        var _date="",time="";
                        if (item.CreateTime != null) {
                            _date = item.CreateTime.replace(/\//g, "");
                            time = eval('new ' + _date).format("yyyy-MM-dd");
                        }
                        _html += '<tr><td>' + _courseName + '</td><td>' + item.Title + '</td><td>' + item.FileName + '</td><td>' + item.Creator + '</td><td>' + time + '</td><td><a href="javascript:deleteRes(\'' + item.Id + '\')"><span class="glyphicon glyphicon-trash"></span> 删除</a></tr>';
                    }
                    $("#well").show();
                }
                else { _html = "<tr><td colspan='6'>暂无内容！</td></tr>"; $("#well").hide();}
                $("#tb1 tbody").html(_html);
            });  
        }
        //删除数据
        function deleteRes(id){
            $.easyPost("@Url.Action("Delete", "StudentResManage")", { "ResourceId": id }, function (data) {
                if (!data.result) { showTips.open(data.message); return; }
                getList(1);
            });
        }
    </script>
</body>
</html>